var xlsx = require('node-xlsx');
var fs = require('fs');
//开始时间
let startTime = new Date().getTime();
//读取文件内容
var obj = xlsx.parse(__dirname + '/test.xlsx');
var excelObj = obj[1].data;
//内容转换
var data = [];
var id = 0;
for (var i in excelObj) {
  for(var j in excelObj[i]){
    var obj = {};
    id++;
    obj.id = id;
    obj.name = excelObj[i][j];
    data.push(obj);
  }
}
//将文件内容插入新的文件中
fs.writeFileSync("test.json", JSON.stringify(data));
//打印日志
let time = ((new Date().getTime()-startTime)/1000).toFixed(2);
console.log("转换完成,文件路径"+__dirname + "/test.json,本次耗时"+time+"秒");